package com.apache.log.common;


import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.env.Environment;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 获取配置文转到map中
 */
public class PropertiesConfig extends PropertyPlaceholderConfigurer {

    private static Environment ctxSysMap = null;

    public static final String MODEL_INDEX="logmodel";
    public static final String MODEL_DETAIL_INDEX="logmodeldetail";
    public static final String OPERATION_INDEX="logoperation";
    private static ExecutorService service;

    public static String getApplicatinConfig(String key) {
        if(null != ctxSysMap) {
            return ctxSysMap.getProperty(key);
        }
        return "";
    }

    public static void setApplicatinConfig(Environment env) {
        if(PropertiesConfig.ctxSysMap == null){
            PropertiesConfig.ctxSysMap = env;
        }
        if(null == service){
            service = Executors.newFixedThreadPool(10);
        }
    }

    public static void submit(Runnable runnable){
        service.submit(runnable);
    }
}
